package com.gzz.manage.sys.roleuser;

import java.util.List;
import org.springframework.stereotype.Repository;
import com.gzz.common.base.BaseDao;

/**
 * @类说明 【角色用户关联】数据访问层
 * @author 高振中
 * @date 2021-02-20 11:34:58
 **/
@Repository
public class RoleUserDao extends BaseDao {
	/**
	 * @方法说明 【角色用户关联】列表
	 */
	public List<RoleUser> list(RoleUserCond cond) {
		RoleUserCond build = RoleUserCond.builder().name(cond.getName()).deptName(cond.getDeptName()).build();
		StringBuilder sql = new StringBuilder();
		sql.append("SELECT t.userId,t.name,d.name deptName,ru.userId ruid ");
		sql.append("FROM sys_user t ");
		sql.append("LEFT JOIN sys_dept d ON t.deptId=d.id ");
		sql.append("LEFT JOIN sys_role_user ru ON t.userId=ru.userId AND ru.roleId =" + cond.getRoleId());
		sql.append(build.where());
		sql.append(" ORDER BY d.id");
		return list(sql.toString(), build, RoleUser.class);
	}
}